String.prototype.trim = function() {

    return this.replace(/(^\s*)|(\s*$)/g, '');
}
window.onload = function() {




    var iframe = document.getElementsByTagName("iframe");
    for (var i = iframe.length - 1; i >= 0; i--) {
        iframe[i].src = iframe[i].getAttribute('data-src');
        iframe[i].width = "100%";
        iframe[i].height = iframe[i].width * 0.75;
    }

    var Ps = document.getElementsByTagName("p");
    for (var i = Ps.length - 1; i >= 0; i--) {

        Ps[i].innerHTML = Ps[i].innerHTML.trim()
        var p_html = Ps[i].innerHTML;

        p_html = p_html.replace(/\s+/g, "").replace(/\&nbsp/g, "").replace(/\<br>/g, "").replace(/\<BR>/g, "").replace(/\<\br>/g, "").replace(/\<\BR>/g, "");
        if (p_html == "") {
            Ps[i].parentNode.removeChild(Ps[i])
        }
        console.log(p_html.indexOf("</strong>"))
        if (p_html.indexOf("</strong>") > -1) {

            Ps[i].style.textIndent = 0;
        }


    }

    var t = window.screen.availHeight+100 + (document.documentElement.scrollTop || document.body.scrollTop);

    for (var i = imgs.length - 1; i >= 0; i--) {
        imgs[i].style.cssText = "";
        if (t >= imgs[i].offsetTop - 30) {
            console.log("t:" + t + "img:" + imgs[i].offsetTop)
            if (imgs[i].getAttribute("data-url") != null) {
                imgs[i].src = imgs[i].getAttribute("data-url");
            } else if (imgs[i].getAttribute("alt_src") != null) {
                imgs[i].src = imgs[i].getAttribute("alt_src");
            } else if (imgs[i].getAttribute("data-cssrc") != null) {
                imgs[i].src = imgs[i].getAttribute("data-csSrc");
            } else if (imgs[i].getAttribute("data-imgsrc") != null) {
                imgs[i].src = imgs[i].getAttribute("data-imgsrc");
            } else if (imgs[i].getAttribute("data-csSrc") != null) {
                imgs[i].src = imgs[i].getAttribute("data-csSrc");
            } else if (imgs[i].getAttribute("data-src") != null) {
                var src = imgs[i].getAttribute("data-src");
                if (src.indexOf('http://mmbiz.qpic.cn') != -1 && src.indexOf('http://read.html5.qq.com/image') == -1) {
                    src = "http://read.html5.qq.com/image?src=forum&q=5&r=0&imgflag=7&imageUrl=" + src;
                }
                imgs[i].src = src;
            }
        };
    }
}


var imgs = document.getElementsByTagName("img");

window.onscroll = function() {
    var t = (document.documentElement.scrollTop || document.body.scrollTop);

    for (var i = imgs.length - 1; i >= 0; i--) {
        if (t   >= imgs[i].offsetTop-window.screen.availHeight - 100) {
            if (imgs[i].getAttribute("data-url") != null) {
                imgs[i].src = imgs[i].getAttribute("data-url");
            } else if (imgs[i].getAttribute("alt_src") != null) {
                imgs[i].src = imgs[i].getAttribute("alt_src");
            } else if (imgs[i].getAttribute("data-cssrc") != null) {
                imgs[i].src = imgs[i].getAttribute("data-csSrc");
            } else if (imgs[i].getAttribute("data-imgsrc") != null) {
                imgs[i].src = imgs[i].getAttribute("data-imgsrc");
            } else if (imgs[i].getAttribute("data-csSrc") != null) {
                imgs[i].src = imgs[i].getAttribute("data-csSrc");
            } else if (imgs[i].getAttribute("data-src") != null) {
                var src = imgs[i].getAttribute("data-src");
                if (src.indexOf('http://mmbiz.qpic.cn') != -1 && src.indexOf('http://read.html5.qq.com/image') == -1) {
                    src = "http://read.html5.qq.com/image?src=forum&q=5&r=0&imgflag=7&imageUrl=" + src;
                }
                imgs[i].src = src;
            }
        };
    }
}